import App from './App'
import mySearch from "./components/my-search/my-search.vue"
import myGoods from "./components/my-goods/my-goods.vue"
import myaddress from "./components/my-address/my-address.vue"
import mysettle from "./components/my-settle/my-settle"
import mylogin from "./components/my-login/my-login"
import myuserinfo from "./components/my-userinfo/my-userinfo"
// #ifndef VUE3
import { $http } from '@escook/request-miniprogram'
import Vue from 'vue'
import store from './store/store.js'
// 配置请求
uni.$http = $http
$http.baseUrl = 'https://api-hmugo-web.itheima.net'
Vue.component("mySearch",mySearch)
Vue.component("myGoods",myGoods)
Vue.component("myaddress",myaddress)
Vue.component("mysettle",mysettle)
Vue.component("mylogin",mylogin)
Vue.component("myuserinfo",myuserinfo)
// 请求拦截器
$http.beforeRequest = function (options) {
  // do somethimg...
  wx.showLoading({
      title: '数据加载中...',
    })
    // console.log(url.indexOf('/my/' !== -1))
  if(options.url.indexOf('/my/' !== -1)){
    options.header = {
      Authorization : store.state.m_user.token
    }
  }
},

$http.afterRequest = function () {
  wx.hideLoading()
}
uni.$showMsg = function(title = '数据加载失败', duration = 1500){
  uni.showToast({
    title,
    duration:1500,
    icon:'none'
  })
}
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
    ...App,
    store
    
})
app.$mount()
// #endif

// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {
  const app = createSSRApp(App)
  return {
    app
  }
}
// #endif